<!--代码逻辑和样式库-->
<script src="./create-department.component.js"></script>
<style src="./create-department.scss" scoped lang="scss"></style>

<template>
  <div>
    <el-dialog :visible.sync="showDialog" width="1300px" @close="closeDialog()">
      <span slot="title">
        <span class="aq-text-weight-bolder">部门管理</span>
        <i class="aq-margin-left-12 aq-margin-right-12 el-icon-arrow-right"></i>
        {{ title }}
      </span>
      <!-- 非组织树编辑 -->
      <el-form v-if="type !== 'editTree'" ref="dataForm" :rules="editRules" :model="editForm" label-position="top" label-width="120px">
        <el-row :gutter="20">
          <el-col :span="5">
            <el-form-item prop="code">
              <div><span class="aq-text-color-danger">*</span>部门编号<span class="aq-search-text">请根据规则填写部门编号</span></div>
              <el-input v-model="editForm.code" />
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item prop="name">
              <div><span class="aq-text-color-danger">*</span>部门名称<span class="aq-search-text">部门名称不可为空</span></div>
              <el-input v-model="editForm.name" />
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="pidObj">
              <div>
                <span class="aq-text-color-danger">*</span>所属组织
                <span v-if="type === 'create'" class="aq-search-text">所属组织已获取组织树选择的上层组织节点,若修改则会建立到其他组织部门下</span>
                <span v-else class="aq-text-color-danger aq-search-text">编辑组织信息时不可修改组织节点</span>
              </div>
              <el-select v-model="editForm.pidObj" value-key="objectId" class="aq-width-full" :disabled="type === 'create'? false : true">
                <el-option v-for="(item, index) in structs" :key="index" :label="item.name" :value="item"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="5" class="aq-vertical-middle">
            <el-form-item prop="pidObj">
              <div>
                <span class="aq-text-color-danger">*</span>是否为工段<span class="aq-search-text">默认创建该部门为非工段信息</span>
              </div>
              <el-switch v-model="editForm.isSection" :active-value="1" :inactive-value="0" active-color="#13ce66" inactive-color="#ff4949">
              </el-switch>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="description">
              <div>部门描述<span class="aq-search-text">可填写部门描述</span></div>
              <el-input v-model="editForm.description" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!-- 组织树编辑 -->
      <el-form v-if="type === 'editTree'" ref="dataForm" :rules="editRules" :model="editForm" label-position="top" label-width="120px">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item prop="name">
              <div><span class="aq-text-color-danger">*</span>部门名称<span class="aq-search-text">部门名称不可为空</span></div>
              <el-input v-model="editForm.name" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer">
        <el-button @click="closeDialog()">取消</el-button>
        <el-button type="primary" :loading="loading" @click="save()">提交数据</el-button>
      </span>
    </el-dialog>
  </div>
</template>
